<?php
class Kc extends CI_Controller{

    private $limit =10;
	function  __construct() {
        parent::__construct();
        $this->load->model('Kc_model');
	$this->load->helper(array('form', 'url'));
	$this->load->library(array('form_validation', 'pagination'));
    }

    function index($offset=''){

          $page=$this->uri->segment(3);
	    $batas=10;
	    if(!$page):
	    $offset = 0;
	    else:
	    $offset = $page;
	    endif;

	    $data['nama']="";
	    $postkata = $this->input->post('nama');
	    if(!empty($postkata))
	    {
	        $data['nama'] = $this->input->post('nama');
	        $this->session->set_userdata('pencarian_kc', $data['nama']);
	    }
	    else
	    {
	        $data['nama'] = $this->session->userdata('pencarian_kc');
	    }
            
	    $data['nama_kc'] = $this->Kc_model->Cari_kc($batas,$offset,$data['nama']);
	    $tot_hal = $this->Kc_model->tot_hal('cabang','strkepala_cabang',$data['nama']);

	    $config['base_url'] = base_url() . 'kc/index/';
	        $config['total_rows'] = $tot_hal->num_rows();
	        $config['per_page'] = $batas;
	        $config['uri_segment'] = 3;
	        $config['full_tag_open'] = '<div id="pagination">';
                $config['full_tag_close'] = '</div>';
	        $this->pagination->initialize($config);
	    $data["paginator"] =$this->pagination->create_links();

	    $this->load->view('admin_views/kc/kc',$data);
    }

 
}
?>
